#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

int n, a[ 101 ], pi[ 200001 ], sum;
bool visit[ 200001 ], used[ 101 ];

void init( )
{
    int i, j;
    scanf("%d", &n);
    sum = 0;
    for ( i = 0; i < n; i++ )
    {
        scanf("%d", &a[ i ]);
        sum += a[ i ];
    }
    sort( a, a + n );
    memset( visit, 0, sizeof( visit ) );
    for ( i = 0; i <= sum / 2; i++ )
        pi[ i ] = -1;
    visit[ 0 ] = true;
    for ( i = n - 1; i >= 0; i-- )
        for ( j = sum; j >= a[ i ]; j-- )
            if ( !visit[ j ] && visit[ j - a[ i ] ] )
            {
                visit[ j ] = true;
                pi[ j ] = i;
            }
    sum /= 2;
}

void work( )
{
    int i, j, k, t;
    bool ac[ 100001 ];
    for ( i = sum; i >= 0; i-- )
    {
        if ( !visit[ i ] || !visit[ i * 2 ] )
            continue;
        memset( used, 0, sizeof( used ) );
        memset( ac, 0, sizeof( ac ) );
        j = pi[ i ]; t = i;
        while ( j != -1 )
        {
            used[ j ] = true;
            t -= a[ j ];
            j = pi[ t ];
        }
        ac[ 0 ] = true;
        for ( j = 0; j < n && !ac[ i ]; j++ )
        {
            if ( used[ j ] )
                continue;
            for ( k = i; k >= a[ j ] && !ac[ i ]; k-- )
                ac[ k ] |= ac[ k - a[ j ] ];
        }
        if ( ac[ i ] )
            break;
    }
    if ( i > 0 )
        printf("%d\n", i);
    else
        if ( a[ 0 ] == 0 )
            printf("0\n");
        else
            printf("-1\n");
}

int main( )
{
    int t, cas = 1;
    scanf("%d", &t);
    while ( t-- )
    {
        init( );
        printf("Case %d: ", cas++);
        work( );
    }
    return 0;
}
